import './styles/index.css';
import 'element-plus/es/components/message/style/css';
import 'element-plus/es/components/notification/style/css';
// 本地SVG图标
import './assets/icons'; // icon
import 'nprogress/nprogress.css';

// 富文本样式
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import { debounce } from 'lodash';
import { createApp, Directive } from 'vue';

// import CommonTable from '@/components/CommonTable/index.vue';
// // 字典标签组件
// import ListContainer from '@/components/ListContainer/index.vue';
// // 分页组件
// import Pagination from '@/components/Pagination/index.vue';
// // 自定义表格工具组件
// import RightToolbar from '@/components/RightToolbar/index.vue';
// import SvgIcon from '@/components/SvgIcon/index.vue';
import { router } from '@/router/index';
// import { createPinia } from 'pinia';
import { setupStore } from '@/store';

import App from './App.vue';
// import defaultSettings from './configs/baseConfig';
const app = createApp(App);
import * as directives from '@/directives';
// import { parseTime, resetForm } from '@/utils/dyTool';
// 全局方法挂载
// app.config.globalProperties.parseTime = parseTime;
// app.config.globalProperties.resetForm = resetForm;

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 16);
        super(callback);
    }
};

// 自定义指令
Object.keys(directives).forEach((key) => {
    app.directive(key, (directives as { [key: string]: Directive })[key]);
});
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
// app.component('ListContainer', ListContainer);
// app.component('CommonTable', CommonTable);
// app.component('SvgIcon', SvgIcon);
// app.component('RightToolbar', RightToolbar);
// app.component('Pagination', Pagination);
app.use(router);
// app.use(createPinia());
// 全局注册 状态管理(store)
setupStore(app);
app.mount('#app');
